import axios from 'axios'

const Mock = require('mockjs')
const Random = Mock.Random

Mock.mock('/api/getExpressList', () => {
  let list = []
  for (let index = 0; index < 30; index++) {
    let listObject = {
      id: Random.integer(0, 10000),
      template_name: Random.name(),
      enable: Random.integer(0, 1),
      status: Random.integer(0, 1),
      createdTime: Random.date('yyyy-MM-dd hh:mm:ss')
    }
    list.push(listObject)
  }
  return {
    data: list
  }
})

Mock.mock('/api/getCompanyList', () => {
  let list = []
  for (let index = 0; index < 30; index++) {
    let listObject = {
      id: Random.integer(0, 10000),
      sort: Random.integer(1, 9999),
      goodsImgUrl: Random.image('60x60', '#894FC4', '#FFF', 'Mock.js'),
      goodsName: Random.name(),
      integral: Random.boolean(),
      createdTime: Random.date('yyyy-MM-dd hh:mm:ss')
    }
    list.push(listObject)
  }
  return {
    data: list
  }
})

Mock.mock('/api/getGoodsList', () => {
  let list = []
  for (let index = 0; index < 30; index++) {
    let listObject = {
      id: Random.integer(0, 10000),
      sort: Random.integer(1, 9999),
      goodsImgUrl: Random.image('60x60', '#894FC4', '#FFF', 'Mock.js'),
      goodsName: Random.name(),
      integral: Random.boolean(),
      integral_num: Random.integer(),
      stock: Random.integer(),
      enable: Random.integer(0, 1),
      status: Random.integer(1, 3),
      createdTime: Random.date('yyyy-MM-dd hh:mm:ss')
    }
    list.push(listObject)
  }
  return {
    data: list
  }
})

Mock.mock('/api/getBuyLogList', () => {
  let list = []
  for (let index = 0; index < 30; index++) {
    let listObject = {
      id: Random.integer(0, 10000),
      avatar: Random.image('60x60', '#894FC4', '#FFF', 'Mock.js'),
      nickName: Random.name(),
      createdTime: Random.date('yyyy-MM-dd hh:mm:ss'),
      integral: Random.integer(),
      userMobile: Random.natural(),
      orderNo: Random.guid(),
      remark: Random.csentence()
    }
    list.push(listObject)
  }
  return {
    data: list
  }
})

Mock.mock('/api/getExchangeRecordList', () => {
  let list = []
  for (let index = 0; index < 30; index++) {
    let listObject = {
      id: Random.integer(0, 10000),
      couponName: Random.name(),
      code: Random.guid(),
      integral: Random.integer(),
      num: Random.integer(),
      nickName: Random.name(),
      phone: Random.id(),
      newStatus: Random.boolean(),
      sotreName: Random.csentence(),
      createdTime: Random.date('yyyy-MM-dd hh:mm:ss')
    }
    list.push(listObject)
  }
  return {
    data: list
  }
})

Mock.mock('/api/getCouponList', () => {
  let list = []
  for (let index = 0; index < 30; index++) {
    let listObject = {
      id: Random.integer(0, 10000),
      couponName: Random.name(),
      sotreName: Random.csentence(),
      total_num: Random.integer(),
      no_stock: Random.integer(),
      exchange: Random.integer(),
      remaining: Random.integer(),
      sort: Random.integer(),
      enable: Random.boolean(),
      void: Random.boolean(),
      createdTime: Random.date('yyyy-MM-dd hh:mm:ss')
    }
    list.push(listObject)
  }
  return {
    data: list
  }
})

// 订单标签
export function getExpressList() {
  return axios.get('/api/getExpressList').then(res => {
    console.log(res.data.data)
    return res.data.data
  })
}

// 订单标签
export function getCompanyList() {
  return axios.get('/api/getCompanyList').then(res => {
    return res.data.data
  })
}

// 商品
export function getGoodsList() {
  return axios.get('/api/getGoodsList').then(res => {
    console.log(res.data.data)
    return res.data.data
  })
}

// 购买记录
export function getBuyLogList() {
  return axios.get('/api/getBuyLogList').then(res => {
    console.log(res.data.data)
    return res.data.data
  })
}

// 兑换记录
export function getExchangeRecordList() {
  return axios.get('/api/getExchangeRecordList').then(res => {
    console.log(res.data.data)
    return res.data.data
  })
}

// 礼品券列表
export function getCouponList() {
  return axios.get('/api/getCouponList').then(res => {
    console.log(res.data.data)
    return res.data.data
  })
}
